package com.zk.h2demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zk.h2demo.dao.UserDao;
import com.zk.h2demo.model.User;


@RestController
@RequestMapping("user")
public class UserController 
{
	@Autowired
	private UserDao userDao;
	
	
	@GetMapping("all")
	public List<User> getAll(){
		return userDao.findAll();
	}
	
	@GetMapping("name")
	public List<String> getByName(String name){
		return userDao.getName(name);
	}
	
	@GetMapping("delete/{id}")
	public void deleteById(@PathVariable long id){
		userDao.deleteById(id);
	}
}
